var app = getApp();
Page({
    data:{
        userInfo: {},
        host: app.d.hostUrl,
        loadingText: '加载中...',
        loadingHidden: false,
        ordersNum:{}
    },

    //初始化数据
    onLoad:function(){
        var that = this;
        app.getUserInfo(function(userInfo){
            that.setData({
                userInfo:userInfo,
                loadingHidden:true
            })
        });
        that.loadOrderStatus();
    },

    //获取订单数量信息
    loadOrderStatus:function(){
        var that = this;
        wx.request({
            url: app.d.hostUrl + '/api/orders/num',
            method: 'get',
            data:{
                user_id: app.d.userId,
            },
            header: {
                'Content-Type':  'application/x-www-form-urlencoded'
            },
            success:function(res){
                var status = res.data.status;

                if(status == 1){
                    that.setData({
                        ordersNum:res.data.info
                    })
                }else{
                  wx.showToast({
                    title: '非法操作.',
                    duration: 2000
                  });
                }
            },
            error:function(e){
                wx.showToast({
                  title: '网络异常！',
                  duration: 2000
                });
            }
        });
    },

});